home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.19981211-19990422 / 000129_news@watsun.cc.columbia.edu _Sat Jan 16 15:15:37 1999.msg < prev    next >
Internet Message Format  |  2020-01-01  |  4KB

  1. Return-Path: <news@watsun.cc.columbia.edu>
  2. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
  3.     by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id PAA03869
  4.     for <kermit.misc@watsun.cc.columbia.edu>; Sat, 16 Jan 1999 15:15:37 -0500 (EST)
  5. Received: (from news@localhost)
  6.     by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id PAA04538
  7.     for kermit.misc@watsun.cc.columbia.edu; Sat, 16 Jan 1999 15:08:29 -0500 (EST)
  8. X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
  9. From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  10. Subject: Re: Telnet macro.  Does it exist?
  11. Date: 16 Jan 1999 20:08:28 GMT
  12. Organization: Columbia University
  13. Message-ID: <77qrjs$4dn$1@newsmaster.cc.columbia.edu>
  14. To: kermit.misc@mailrelay2.cc.columbia.edu
  15.  
  16. In article <77p8q2$r4n$1@jupiter.mcs.net>, Leslie Mikesell <les@MCS.COM> wrote:
  17. : In article <369F9217.576CB86C@newbridge.com>,
  18. : Christian Brideau  <cbrideau@newbridge.com> wrote:
  19. : >I want to automate complete telnet sessions.  In other words, logon-do
  20. : >stuff-get out.
  21. : >
  22. : >Is this scriptable?  If not is there a macro software out there that I
  23. : >could use to perform this task?
  24. : Kermit from http://www.columbia.edu/kermit/ has a reasonable scripting
  25. : language that works the same with serial ports or telnet sessions.
  26. Right.  This is a better solution than expect combined with regular telnet,
  27. since it is self-contained, eliminating timing and coordination problems that
  28. might occur between the two local applications, on top of whatever might
  29. happen at the remote end.
  30.  
  31. A typical Kermit script for making a Telnet connection might look like this;
  32. this assumes you already have the following variables set:
  33.  
  34.   \%h = hostname
  35.   \%u = username on host
  36.   \%p = password for user on host
  37.   \%s = shell prompt on host (e.g. \13\10$\32)
  38.  
  39. Backslash followed by digit indicates an ASCII character value, so the
  40. prompt example means "carriage return, linefeed, dollar sign, space" or
  41. (in plain words) a dollar sign on the left margin.
  42.  
  43. These can be set in any of various ways -- hardwired into the script
  44. (bad idea), prompted for interactively, taken from environment variables,
  45. read from a database, etc.  Here's the script:
  46.  
  47.   set host \%h                          ; Make the connection
  48.   if failure stop 1 Connection failure  ; Check for failure
  49.   input 30 login:                       ; Wait 30 sec for login: prompt.
  50.   if failure stop 1 No login prompt     ; Give up on timeout
  51.   output \%u\13                         ; Send user ID and carriage return.  
  52.   input 10 Password:                    ; Wait 10 sec for Password: prompt.
  53.   output \%p\13                         ; Send password and carriage return.  
  54.   input 60 \%s                          ; Wait 60 sec for shell prompt.
  55.  
  56. Now you're logged in and ready to give system commands, for example:
  57.  
  58.   output kermit -x\13                   ; Start remote Kermit in server mode.
  59.   send neworders.txt                    ; Tell local Kermit to send a file.
  60.   if success delete neworders.txt       ; Delete source file if OK.
  61.   get inventory.txt                     ; Download a file from the server
  62.  
  63. etc etc.  When done:
  64.  
  65.   bye                                   ; Shut down and log out the server.
  66.   exit
  67.   
  68. The "exit" command automatically closes the connection.
  69.  
  70. This simple example should be enough to get you started.  There's lots more;
  71. loops, functions, arrays, etc.  More info at:
  72.  
  73.   http://www.columbia.edu/kermit/ckermit.html
  74.  
  75. - Frank